/*
 * thread.c
 *
 *  Created on: 2011-10-29
 *      Author: poseidon
 */

#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pthread.h>
#include <sched.h>
#include <unistd.h>

#include "types.h"
#include "define.h"
#include "thread.h"

void start_thread(Pthreadstruct thread, pvoid app_param, thread_function thread_loop) {
	pthread_attr_init(&thread.ptattr);
	pthread_attr_setscope(&thread.ptattr, PTHREAD_SCOPE_SYSTEM);
	pthread_create(&thread.ptid, &thread.ptattr, thread_loop, app_param);
}

void set_thread_priority(Pthreadstruct thread, int npriority) {
	pthread_getschedparam(thread.ptid, &thread.policy, &thread.ptprior);
	thread.policy = SCHED_RR;
	thread.ptprior.__sched_priority = npriority;
	pthread_setschedparam(thread.ptid, thread.policy, &thread.ptprior);
}
















